//
//  CQRootTool.m
//  01-OC微博
//
//  Created by 陈乾 on 15/11/2.
//  Copyright © 2015年 陈乾. All rights reserved.
//

#import "CQRootTool.h"
#import "CQTabBarController.h"
#import "CQNewFeatureController.h"
#define CQVersionKey @"version"
@implementation CQRootTool

/**
 *  选择新特性界面
 */
+ (void) choseNewFeatureViewController:(UIWindow*)window {
    //获取当前的版本号
    NSString *newVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleVersion"];
    //获取偏好设置的版本号
    NSString *lastVersion = [[NSUserDefaults standardUserDefaults] objectForKey:CQVersionKey];
    //比较
    if ([newVersion isEqualToString:lastVersion]) {
        
        CQTabBarController *tabBarVc = [[CQTabBarController alloc] init];
        window.rootViewController = tabBarVc;
        
    }else//有新版本了 需要新特性
    {
        CQNewFeatureController *newFeatureVc = [[CQNewFeatureController alloc] init];
        window.rootViewController = newFeatureVc;
        //保存到沙盒
        [[NSUserDefaults standardUserDefaults] setObject:newVersion forKey:CQVersionKey];
    }
    
}

@end
